{include file="public/top" /}
<div class="layui-container">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md8 content detail">
			<div class="fly-panel detail-box">
				<h1>{:$ques.title}</h1>
				<div class="fly-detail-info">
					<span class="layui-badge layui-bg-green fly-detail-column">{:$ques.cate_name}</span>
					<span class="layui-badge" style="background-color: #999;">{:$ques.status==1 ? '已结' : ' 未结'}</span>
					<div class="fly-admin-box" data-id="43125"></div>
					<span class="fly-list-nums">
                                <a href="#comment">
                                    <i class="iconfont" title="回答">&#xe60c;</i>{:$ques.reply_num}</a>
                                <i class="iconfont" title="人气">&#xe60b;</i>{:$ques.view_num}</span></div>
				<div class="detail-about">
					<a class="fly-avatar" href="{:url('index/HomePage/index',['user_id'=>$ques.user_id])}">
						<img src="__STATIC__/{:$ques.face}" alt="{:$ques.nickname}"></a>
					<div class="fly-detail-user">
						<a href="{:url('index/HomePage/index',['user_id'=>$ques.user_id])}" class="fly-link">
							<cite>{:$ques.nickname}</cite></a>
						<span>{$ques.create_time|date="Y/m/d H:s:i",###}</span></div>
					<div class="detail-hits" id="LAY_jieAdmin" data-id="43125">
						<span style="padding-right: 10px; color: #FF7200">悬赏：{:$ques.kiss}飞吻</span>
						{if condition='$collect'}
						<span class="layui-btn layui-btn-xs jie-admin  layui-btn-danger" id="collect"
							  question_id="{:$ques.question_id}" type="collect" data-type="add">取消收藏</span>
						{else/}
						<span class="layui-btn layui-btn-xs jie-admin " id="collect" question_id="{:$ques.question_id}"
							  type="collect" data-type="add">收藏</span>
						{/if}
					</div>
				</div>
				<div class="detail-body layui-text photos">
					<table class="layui-table">
						{in name="ques.cate_id" value="1"}
						<tbody>
						<tr>
							<td>版本：{:$ques.version}</td>
							<td>浏览器：{:$ques.browser}</td>
						</tr>
						</tbody>
						{/in}
					</table>
					{:$ques.content}
				</div>
				<a name="sb"></a>
			</div>
			<div class="fly-panel detail-box" id="flyReply">
				<fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
					<legend>回帖</legend>
				</fieldset>
				{if condition='$reply'}
				<ul class="jieda" id="jieda">
					{volist name='reply' id='row'}
					<li data-id="145054">
						<div class="detail-about detail-about-reply">
							<a class="fly-avatar" href="{:url('index/HomePage/index',['user_id'=>$row.user_id])}">
								<img src="__STATIC__/{$row.face}" alt="{$row.nickname}"></a>
							<div class="fly-detail-user">
								<a href="{:url('index/HomePage/index',['user_id'=>$row.user_id])}" class="fly-link">
									<cite>{$row.nickname}</cite></a>
							</div>
							<div class="detail-hits">
								<span>{$row.create_time|date='Y/m/d H:i:s',###}</span></div>
						</div>
						<div class="detail-body layui-text jieda-body photos">
							{$row.content}
						</div>
						<div class="jieda-reply">
                                    <span class="jieda-zan " type="zan">
                                        <i class="iconfont icon-zan zan " reply_id="{$row.reply_id}"></i>
                                        <em>{$row.zan_num}</em>
									</span>
									<span type="reply" class="reply" user_id="{$row.user_id}" nickname="{$row.nickname}">
										<a href="#ss"><i class="iconfont icon-svgmoban53"></i>回复</a>
									</span>
						</div>
					</li>
					{/volist}
					<a name="ss"></a>
				</ul>
				{else/}
				<ul class="jieda" id="jieda">
					<li class="fly-none">消灭零回复</li>
				</ul>
				{/if}
				<div style="text-align: center"></div>
				<div class="layui-form layui-form-pane">
					<form action="" method="post">
						<div class="layui-form-item layui-form-text">
							<div class="layui-input-block">
								<textarea id="L_content" name="content" required placeholder="请输入内容"
										  class="layui-textarea fly-editor" style="height: 150px;"></textarea>
							</div>
						</div>
						<div class="layui-form-item">
							<input type="hidden" name="question_id" value="{:$ques.question_id}">
							<!--<input type="hidden" name="daPages" value="1">-->
							<button class="layui-btn" lay-filter="reply" lay-submit>提交回复</button>
						</div>
					</form>
				</div>
			</div>
		</div>
		{include file="public/right" /}
	</div>
</div>
<script>
    //Demo
    layui.use(['form', 'layedit'], function () {
        var form = layui.form;
        var layedit = layui.layedit;
        layedit.set({
            uploadImage: {
                url: '{:url("index/Posted/upload")}' //接口url
                , type: 'post' //默认post
            }
        });
        index = layedit.build('L_content');

        $('.reply').click(function () {
            nickname = $(this).attr('nickname');
			id = $(this).attr('user_id');
			location.href='#ss';
            str = "@ <a href='{:url('index/HomePage/index')}?user_id="+id+"'>"+nickname+"</a>  ";
            layedit.setContent(index,str);
        })

        $('.zan').click(function () {
            reply_id = $(this).attr('reply_id');
            that = $(this);
            $.post("{:url('index/Nom/like')}", {reply_id: reply_id}, function (res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 9}, function () {
                    });
                } else {
                }
            });
        })

        $('#collect').click(function () {
            question_id = $(this).attr('question_id');
            $.post("{:url('index/Nom/collect')}", {question_id: question_id}, function (res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, {time: 500}, function () {
                    });
                } else {
                    if (res.msg == '已收藏') {
                        $('#collect').addClass('layui-btn-danger');
                        $('#collect').html('取消收藏');
                    } else {
                        $('#collect').removeClass('layui-btn-danger');
                        $('#collect').html('收藏');
                    }
                    layer.msg(res.msg, {time: 500}, function () {
                    });
                }
            });
        })
        //监听提交
        form.on('submit(reply)', function (data) {
            data.field.content = layedit.getContent(index);
            $.post("{:url('index/Nom/reply')}", data.field, function (res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 9}, function () {
                    });
                } else {
						location.href='#sb';
                        location.reload();
                }
            });
            return false;
        });
    });
</script>
